import dialogForm from './edit'              //弹窗组件
import agentHttp from '@/utils/agentHttp'    //请求方法
import pagination from '@/views/pagination'  //分页组件
import {confirm} from '@/utils/confirm'      //二次确认组件
import {debounce} from '@/utils/index.js'
export default {
  name: 'hotBrands',
  components:{dialogForm,pagination},
  created(){
      this.seachData({})
  },
  data() {
    return {
      //表格字段
      tableData: [{}],

      //弹窗状态数据
      dialogSendData:{
        isAdd:"",
        dialogFormVisible:"",
        id:""
      },
      searchForm:{name1:""},
      options:[{value:"1",label:"1"}],
      resetFormStatus:false
    }
  },
  methods: {
    seachData(){
      if(!this.resetFormStatus){
        var params=this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        agentHttp.post('adminApi/admin/carousel/queryAllByEntity',params ).then((data)=>{
              this.tableData = data
        })
      }
    },
    resetSearchForm(formName) {
      this.resetFormStatus=true;
      this.tableData.page=1;
      this.tableData.rows=10;
      this.$refs[formName].resetFields();
      this.$nextTick(_ =>{
        this.resetFormStatus=false;
        this.seachData();
      })
    },
    
    /*表格操作按钮*/
    //删除
    handleDisabled(index, row){
        confirm(()=>{
          agentHttp.del('adminApi/admin/carousel/'+row.id).then((data)=>{
            if(data.success){  
               this.$message.success(data.data||(this.$refs.flag.$el.textContent+"成功"));
                this.seachData({});
                //这里编写数据赋值或者其他逻辑  例如：this.tableData = data;
            } 
          })
        },()=>{
           this.$message.info('已取消'+this.$refs.flag.$el.textContent); 
        },"确认"+this.$refs.flag.$el.textContent+"该条数据吗?")
    },
    //新增、编辑
    handleEdit(index, row){
      row?this.dialogSendData.id=row.id:this.dialogSendData.id="";
      this.dialogSendData.isAdd=true;
      this.dialogSendData.dialogFormVisible=true;
    },
    //查看
    handleSee(index, row){
      row?this.dialogSendData.id=row.id:this.dialogSendData.id="";
      this.dialogSendData.isAdd=false;
      this.dialogSendData.dialogFormVisible=true;
    }
  }
}